<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Login</title>

    <link rel="stylesheet" type="text/css" media="screen" href="<?= THEMEPATH ?>/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" media="screen" href="<?= THEMEPATH ?>/css/font-awesome.min.css"/>
    <link rel="stylesheet" type="text/css" media="screen" href="<?= THEMEPATH ?>/css/login.css"/>
    <link rel="stylesheet" type="text/css" media="screen" href="<?= THEMEPATH ?>/css/bootstrap-dialog.min.css"/>


    <script src="<?= THEMEPATH ?>/js/jquery.min.js"></script>
    <script src="<?= THEMEPATH ?>/js/bootstrap.min.js"></script>
    <script src="<?= THEMEPATH ?>/js/custom.js"></script>
    <script src="<?= THEMEPATH ?>/js/bootstrap-dialog.min.js"></script>

</head>
<body>

<?php echo validation_errors(); ?>

<div class="login-div">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4>考生登陆</h4>
        </div>
        <div class="panel-body">

            <p class="bg-warning hidden" id="error_message"></p>

            <form class="form" id="login-form" action="<?= site_url('/login') ?>" method="post">
                <div class="form-group div-bor">
                    <i class="icon-user"></i>
                    <input class="form-control" data-required="true" title="用户名" placeholder="USERNAME" name="username" type="text" maxlength="20" value="" />
                </div>

                <div class="form-group div-bor">
                    <i class="icon-key"></i>
                    <input class="form-control" data-required="true" title="密码" placeholder="PASSWORD" name="password" type="password" maxlength="32" value="" />
                </div>

                <input class="btn btn-primary btn-lg btn-block" type="submit" value="登 录"/>
                <hr/>
                <div class="text-right">
                    <a href="javascript:void(0);" data-open="<?=site_url('/register')?>" data-size="ma" title="考生注册">现在注册</a>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="<?= THEMEPATH ?>/js/validator.js"></script>

<script type="text/javascript">
    $(function () {
        $('#login-form').formValidator({
            sending: {
                type: 'ajax',
                success: function (data) {
                    var e = $.parseJSON(data);
                    if (e.error) {
                        show_error({'message': e.error, 'color': 'danger'});
                    } else {
                        show_error(e.success);
                        window.location.href="<?=site_url('main');?>";
                    }
                },
                error: function () {
                    show_error("提交失败！");
                }
            }
        });
    });
</script>

</body>
</html>